package logic

import (
	"context"
	"teacher1/teacherrpc/teacherrpc"

	"teacher1/api/internal/svc"
	"teacher1/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type TeacherRegisterLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewTeacherRegisterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TeacherRegisterLogic {
	return &TeacherRegisterLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *TeacherRegisterLogic) TeacherRegister(req *types.TeacherRegisterRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	register, err := l.svcCtx.TeacherRpc.TeacherRegister(l.ctx, &teacherrpc.TeacherRegisterRequest{
		Mobile:      req.Mobile,
		SendSmsCode: req.SendSmsCode,
	})
	if err != nil {
		return &types.Response{
			Msg:  "注册失败" + err.Error(),
			Code: 500,
			Data: nil,
		}, nil
	}
	return &types.Response{
		Msg:  "注册成功",
		Code: 200,
		Data: register,
	}, nil
}
